package com.sline.TCP;

import java.io.*;
import java.net.Socket;
import java.util.Scanner;

public class Demo1_Client {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1", 12345);
        InputStream is = socket.getInputStream();
        OutputStream os = socket.getOutputStream();

        Scanner sc = new Scanner(System.in);
        while (true) {
            String line = sc.nextLine();
            os.write(line.getBytes());

            byte[] arr = new byte[1024];
            int len = is.read(arr);
            String msg = new String(arr, 0, len);

            System.out.println("客户端收到数据: " + msg);
        }


    }
}
